package gov.pbc.nn.kjgl.software.handle;

import gov.pbc.nn.core.utils.SecurityUtils;
import gov.pbc.nn.kjgl.Constants;
import gov.pbc.nn.kjgl.entity.Project;
import gov.pbc.nn.kjgl.software.dao.ProjectDao;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.bstek.bdf2.core.business.IUser;
import com.bstek.uflo.env.Context;
import com.bstek.uflo.model.ProcessInstance;
import com.bstek.uflo.process.handler.AssignmentHandler;
import com.bstek.uflo.process.node.TaskNode;

@Component("kjleader.AssignmentHandler")
public class KjLeaderAssignmentHandler implements AssignmentHandler {
	@Autowired
	private ProjectDao dao;

	@Override
	public Collection<String> handle(TaskNode taskNode, ProcessInstance processInstance, Context context) {
		String businessId = processInstance.getBusinessId();
		Project project = dao.getProjectById(businessId);
		Collection<String> list = new ArrayList<String>();
		List<IUser> czUsers = SecurityUtils.getUserByRoleForZZ(project.getYwzgDeptId(),Constants.ROLE_LXSHY);
		if (czUsers.size() > 0) {
			list.add(czUsers.get(0).getUsername());
		}
		return list;
	}

}
